#include "beep.h"
#include <basic.h>
#include <gpio.h>

#define BEEP_PORT GPIO_PORT_1
#define BEEP_PIN GPIO_PIN_3

void beepInit()
{
    GPIO_Init(BEEP_PORT, BEEP_PIN, GPIO_MODE_PUSH_PULL);
}
void beepOn()
{
    GPIO_State xdata state = GPIO_STATE_LOW;
    uint8_t xdata i = 0;
    for (i = 0; i < 100; i++)
    {
        GPIO_Set(BEEP_PORT, BEEP_PIN, state);
        delay_us(400);
        state = (state == GPIO_STATE_LOW) ? GPIO_STATE_HIGH : GPIO_STATE_LOW;
    }
    GPIO_Set(BEEP_PORT, BEEP_PIN, GPIO_STATE_LOW);
}

void beepOff()
{
    GPIO_Set(BEEP_PORT, BEEP_PIN, GPIO_STATE_LOW);
}